import dataProvider from '../../../service/dataProvider'
const app = getApp()
Page({
  data: {
    shares: dataProvider.shares,
    share: {
      title: '逼疯外地人的30句重庆话，看到第一句重庆人都跪服了！',
      describle: '',
      image: ''
    },
    list: []
  },
  onLoad: function (opt) {
    console.log('onLoad')
    const that = this;
    const categoryId = opt.id;
    const list = dataProvider.list;
    that.setData({
      list: list.filter(item => item.categoryId == categoryId)
    });
  },
  onShareAppMessage: function () {
    let share = this.data.shares[Math.floor(Math.random() * this.data.shares.length)];
    return {
      title: share.title,
      // desc: '',
      path: '/pages/list/index',
      imageUrl: share.imageUrl
    }
  },
  showDetail: function (e) {
    // 跳转详情页
    var item = e.currentTarget.dataset.item;
    if(item.categoryId == 1 || item.categoryId == 2) {
      wx.navigateTo({
        url: "../../detail/index?id=" + item.id
      });
    }
  },
})

